#ifndef __TYPES_H
#define __TYPES_H

#ifndef u8
typedef unsigned char u8;
#endif

#ifndef s8
typedef char s8;
#endif

#ifndef u16
typedef unsigned short u16;
#endif

#ifndef s16
typedef short s16;
#endif

#ifndef u32
typedef unsigned int u32;
#endif

#ifndef s32
typedef int s32;
#endif

#ifndef u64
typedef unsigned long long u64;
#endif

#ifndef s64
typedef long long s64;
#endif

#ifndef Bool
typedef unsigned char Bool;
#endif

/* exact-width signed integer types */
#ifndef int8_t
typedef signed char int8_t;
#endif
#ifndef int16_t
typedef signed short int int16_t;
#endif
#ifndef int32_t
typedef signed int int32_t;
#endif

/* exact-width unsigned integer types */
#ifndef uint8_t
typedef unsigned char uint8_t;
#endif

#ifndef uint16_t
typedef unsigned short int uint16_t;
#endif

#ifndef uint32_t
typedef unsigned int uint32_t;
#endif

#ifndef uint64_t
typedef unsigned long long uint64_t;
#endif

#ifndef int64_t
typedef long long int64_t;
#endif

#ifndef true
#define true 1
#endif

#ifndef false
#define false 0
#endif

#ifndef TRUE
#define TRUE ((Bool)1)
#endif

#ifndef FALSE
#define FALSE ((Bool)0)
#endif

struct fpga_message_s
{
    int addr;
    int value;
};

enum commonDataType
{
    COM_DATA_TYPE_NONE = 0,
    COM_DATA_TYPE_UINT8 = 1,
    COM_DATA_TYPE_INT8,
    COM_DATA_TYPE_UINT16,
    COM_DATA_TYPE_INT16,
    COM_DATA_TYPE_UINT32,
    COM_DATA_TYPE_INT32,
    COM_DATA_TYPE_UINT64,
    COM_DATA_TYPE_INT64,
    COM_DATA_TYPE_FLOAT,
};

union commonDataValue
{
    uint8_t uint8Value;
    int8_t int8Value;
    uint16_t uint16Value;
    int16_t int16Value;
    uint32_t uint32Value;
    int32_t int32Value;
    uint64_t uint64Value;
    int64_t int64Value;
    float floatValue;
    uint8_t byteValue[8];
};

struct commonData
{
    enum commonDataType cd_dataType;
    union commonDataValue cd_dataValue;
};



typedef enum __funcMainType__
{
    LOG_MAINTYPE_FAULT = 0, /* 故障 */
    LOG_MAINTYPE_COMM,      /* 通讯 */
    LOG_MAINTYPE_CMD_TIP,   /* 命令提示 */
    LOG_MAINTYPE_SYS_TIP,   /* 系统提示 */
    LOG_MAINTYPE_RSV1,       /* 触摸屏记录 */
    LOG_MAINTYPE_RSV2,       /* 后台记录 */
    LOG_MAINTYPE_RSV3,       /* 电池记录 */
    LOG_MAINTYPE_CUR_FAULT, /* 当前故障 */
    LOG_MAINTYPE_MISC,      /* 杂项 */
    LOG_MAINTYPE_IO,        /* IO状态 */

    LOG_MAINTYPE_OPERATOR_BEGIN = 100,
    LOG_MAINTYPE_INIT = LOG_MAINTYPE_OPERATOR_BEGIN,                /* 初始化 */
    LOG_MAINTYPE_UPPER,                                             /* 上位机 */
    LOG_MAINTYPE_EMS,                                               /* EMS */
    LOG_MAINTYPE_LC,                                                /* LC */
    LOG_MAINTYPE_BMS,                                               /* BMS */
    LOG_MAINTYPE_DCDC,                                              /* DCDC */
    LOG_MAINTYPE_HMI,                                               /* 触摸屏 */
    LOG_MAINTYPE_RATED_LIMIT,                                       /* 限额 */
    LOG_MAINTYPE_PULSE_OPERATE,                                     /* 脉冲操作 */
    LOG_MAINTYPE_TEMP_SAMPLE,                                       /* 温度采样 */
    LOG_MAINTYPE_OVER_TEMP,                                         /* 过温 */
    LOG_MAINTYPE_OVER_LOAD,                                         /* 过载 */
    LOG_MAINTYPE_OVER_UNDER_VOL,                                    /* 过欠压 */
    LOG_MAINTYPE_OVER_UNDER_FREQ,                                   /* 过欠频 */
    LOG_MAINTYPE_1547,                                              /* 1547 */
    LOG_MAINTYPE_TIME_PERIOD,                                       /* 时间段 */

    LOG_MAINTYPE_MAX,
} FuncMainType;


typedef enum __logType__
{
    upload_log = 1,     /*上位机所需日志*/
    local_log,          /*本地日志*/
} LogType;


typedef struct __logData__
{
    char logTimeStamp[16];             
    LogType logType;
    FuncMainType logFuncMainType;
    uint16_t logFuncSubType;
    enum commonDataType logDataType;
    union commonDataValue logDataValue;
} LogClassData;
#endif